package gr.barbarosa.sshRemote.sdManipulation;

import android.os.Environment;
import android.util.Log;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

import gr.barbarosa.sshRemote.constants.constants;

/**
 * Created by ilias.karditsis on 12/5/2014.
 */
public class createDemoCommandFile {
    private static final String TAG="createDemoCommandFile";


    private static String commandFileText = "<command>\n" +
            "<icon-name>demo.png</icon-name>\n" +
            "<command-name>Demo</command-name>\n" +
            "<command-exec>demo</command-exec>\n" +
            "</command>";


    public static void writeDemoFile() {

        try {
            File statText = new File(Environment.getExternalStorageDirectory() + File.separator+constants.mainAppFolderName+File.separator + constants.commandsAppFolder + File.separator + "demo.xml");
            if (!statText.exists()){
                statText.createNewFile();
            }
            FileOutputStream is = new FileOutputStream(statText);
            OutputStreamWriter osw = new OutputStreamWriter(is);
            Writer w = new BufferedWriter(osw);
            w.write(commandFileText);
            w.close();
        } catch (IOException e) {
            Log.v(TAG, e.toString());
        }


    }


}
